home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5080 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.7 KB  |  39 lines

  1. Newsgroups: comp.lang.fortran,comp.lang.c++
  2. Path: thor.cf.ac.uk!news
  3. From: ghassempoory@cf.ac.uk (M. Ghassempoory)
  4. Subject: Re: How to link Fortran with c++  ??
  5. Sender: news@cf.ac.uk (USENET News System)
  6. Message-ID: <DM5FB9.4vK@cf.ac.uk>
  7. Date: Fri, 2 Feb 1996 12:42:45 GMT
  8. X-Nntp-Posting-Host: giap.elsy.cf.ac.uk
  9. Content-Type: Text/Plain; charset=US-ASCII
  10. References: <310DD74F.59E2@imacsg1.epfl.ch> <4env5h$3ai@nms.telepost.no> <3110887E.41C6@imacsg1.epfl.ch>
  11. Mime-Version: 1.0
  12. Organization: ENGIN - UWCC
  13. X-Newsreader: WinVN 0.99.7
  14.  
  15. In article <3110887E.41C6@imacsg1.epfl.ch>, Niels@imacsg1.epfl.ch says...
  16. >
  17. >As understand it, this is the way to go if you want to call fortran routines 
  18. >in a c++ code. But what if you  want to do go the other way around ? 
  19. >
  20. >So how do I call an data member from a c++ class in fortran ?
  21. >say I want to call a member function called GetData() in fortran so
  22. >how do I transplate Class->GetData() in fortran ?
  23. >
  24.  
  25. This is rather more difficult. To my knowlegde there are no standard 
  26. methods for C++ call handling. So if your get this working by some trick
  27. you may fail to make it work on any other machine. You could write a small C++
  28. jacket which accepts opject A by reference and calls A.GetData() and call this
  29. jacket from fortran: 
  30.      
  31.       CALL GET_DATA_JACKET(OBJ, DATA)
  32.  
  33. However the C++ compiler mangles the names of routines. So your GET_DAT_JACKET
  34. symbol would not be resolved unless you have a look at the map files for the 
  35. true name (Something like GET_DATA_JACKETaB_12_876YFgDR... ) and use that name 
  36. in fortran. Some compilers like GCC will let you define the true name by 
  37. __asm__ directive. It is all very tricky and messy and not worth it at all.
  38.  
  39.